fix(auth): add timeout handling for OAuth fetch requests - #220
Conversation
|
Warning Review limit reached
More reviews will be available in 43 minutes and 26 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdded OAuth-specific request timeout handling to the authentication controller's shared ChangesOAuth Request Timeout Protection
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@yash-pouranik Applied lightweight timeout protection to the OAuth fetch helper using AbortController. Added timeout cleanup and graceful abort handling without changing the existing auth flow. |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/dashboard-api/src/controllers/auth.controller.js`:
- Around line 101-107: Replace the raw Error throws in the response handling
blocks (the if (!response.ok) branch and the similar block at lines ~111-115)
with AppError instances: construct an AppError using the resolved message
(payload?.error_description || payload?.error || payload?.message ||
defaultMessage), set a suitable HTTP statusCode derived from response.status or
a default like 502, and include the original payload/response details as
non-sensitive context (e.g., in a meta/cause property) so controller error
middleware can handle it consistently; update imports to ensure AppError is
available in this file.
- Line 98: The fetch call allows options.signal to override the timeout
controller, so the timeout can be bypassed; change the argument order so the
controller's signal wins (pass options first and controller.signal last) when
calling fetch in the auth controller (the line with controller and options used
in the fetch call), and ensure you handle the case where options is undefined
before merging so the controller.signal is always applied.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 6638bcec-68d8-4c61-9b81-95c11f91e5ca
📒 Files selected for processing (1)
apps/dashboard-api/src/controllers/auth.controller.js
8250e47 to
120a5f0
Compare
| resetPasswordSchema, | ||
| verifyOtpSchema | ||
| } = require("@urbackend/common"); | ||
| const AppError = require("@urbackend/common/src/utils/AppError"); |
There was a problem hiding this comment.
This is not the standard to require the common package, please follow the current code practices, like in line 16, @udaycodespace
|
@yash-pouranik fixed the import part as well 👍
|
|
Ok got it |
Fixes #208
🛠️ Type of Change
🧪 Testing & Validation
Backend Verification:
Frontend Verification:
🔍 Proof of Work
auth.controller.jsAbortControllerto prevent long-running external requestsclearTimeout✅ Checklist
Built with ❤️ for urBackend.
Summary by CodeRabbit